<template>
	<view class="searchPackageSharing">
		<view class="searchBox marginTop10 disFlex" >
			<view class="left">
				<image src="../../../static/img/each.png" mode=""></image>
				<input  confirm-type="search" v-model="updata.text" placeholder="输入搜索关键词" @confirm="getinfo()"/>
			</view>
			<view class="right" @tap="getnav(router(`packageSharing`))"> 
				<view>筛选</view>
				<image src="../../../static/img/shaixuan.png" mode=""></image>
			</view>
		</view>
		<view class="list" v-if="info.length">
			<view class="activeList" v-for="(v,i) in info" :key='i' @tap="toproject(v.id)">
				<view v-if="v.types!=null" class="iconstxt">{{v.types.name}}</view>
				<image :src="v.cover" mode=""></image>
				<view class="line2 describe">{{v.title}}</view>
				<view class="priceBox">
					<text class="price">{{v.cost}}</text>
					<text class="word" style="color: #ccc;">非会员价</text>
				</view>
				<view  class="priceBox" style="margin-top: -5rpx;">
					<text class="price">{{v.member_price==null?v.cost:v.member_price}}</text>
					<text class="word" style="color: red;">会员价</text>
				</view>
			</view>
		</view>
		<view class="listnull" v-else>
			<image src="../../../static/img/fail.png" mode=""></image>
			<view class="text">
				搜索结果为空
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info:[],
				len:'',
				updata:{
					text:"",
				},
				page:1,
			}
		},
		onLoad(option) {
			console.log(option)
			this.updata.text=option.id
			this.getinfo()
		},
		methods: {
			getinfo(page){
				if(page>1){
					this.updata.page=page
				}else{
					delete this.updata.page
				}
				this.http('/api/project/lists', 'post', this.updata, )
					.then((res) => {
						if(page>1){
							if(res.data.data.length>0){
								res.data.data.map((v)=>{
									this.info.push( v)
								})
							}else{
								uni.showToast({ title: '已经没有数据了!', icon: 'none' })
							}
							
						}else{
							this.info = res.data.data
						}
					
					console.log(this.info)
					})
			},
			toproject(v){
				uni.navigateTo({
					url: '/pages/index/programme/programmeDetail?id=' + v
				});
			},
		},
		onReachBottom(){
			uni.showLoading({
			    title: '加载中'
			});
			this.getinfo(++this.page)
			setTimeout(function () {
			    uni.hideLoading();
			}, 1000);
		},
	}
</script>

<style lang="less">
	.listnull{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-top: 100rpx;
		image{
			width: 100rpx;
			height: 100rpx;
			// margin: 0 auto;
		}
		.text{
			font-size: 30rpx;
			color: #ccc;
			
		}
	}
	.searchPackageSharing{
		padding: 0 40rpx;
		.searchBox{
			
			.left{
				display: flex;
				align-items: center;
				flex: 1;
				padding: 0 30rpx;
				height:80rpx;
				background:rgba(245,245,249,1);
				border-radius:40rpx;
				margin-right: 27rpx;
				image{
					width: 34rpx;
					height: 34rpx;
				}
				input{
					padding-left: 8rpx;
					width: 100%;
				}
			}
			.right{
				display: flex;
				align-items: center;
				view{
					font-size: 32rpx;
					color: #BEC9D7;
				}
				image{
					width: 32rpx;
					height: 32rpx;
					margin-left: 10rpx;
				}
			}
		}
		
		.list{
			display: flex;
			align-items: center;
			justify-content: space-between;
			flex-wrap: wrap;
			margin-top: 22rpx;
			.activeList{
				width: 325rpx;
				margin-top: 32rpx;
				position:relative;
				.iconstxt {
					height: 36rpx !important;
					background-color: #FFCF59;
					border-radius: 16px 0px 16px 0pX;
					padding: 0 23rpx;
					position: absolute;
					top: -8rpx;
					left: -8rpx;
					color: #fff;
					font-size: 24rpx;
					z-index: 888;
				}
				image{
					width: 100%;
					height: 188rpx;
					border-radius: 20rpx;
				}
				.describe{
					font-size: 24rpx;
					padding-top: 10rpx;
				}
				.priceBox{
					margin-top: 25rpx;
					display: flex;
					align-items: center;
					.price{
						color: #FE7203;
						&::before{
							padding-right: 10rpx;
						}
					}
					.word{
						font-size: 20rpx;
						color: #BEC9D7;
						padding-left: 10rpx;
					}
				}
			}
		}
	}
</style>
